#include <stdint.h>
#include <string.h>
#include <glib.h>
#include <sys/stat.h>
#include "hw/misc/cJSON.h"
#include "hw/misc/utils.h"

#define MAX_TEMP_VALUES 2
#define MAX_SIZE 256
#define MAX_KEY_LEN 50
#define MAX_SLOT_NUM 10
#define ID_LEN 8
#define BYTES_NUM 4
#define IMU_MOCK_PATH "./output/data/mockdata/IMU/imu_info.json"
#define PCIE_FILE "./output/data/mockdata/IMU/pcie_card.json"

typedef struct
{
	char device_addr[7]; // 存储pcie bdf,每个值2 bytes,共6 bytes,加上'\0'结束符
	uint8_t id_values[2][4]; // id 和auxid
} mock_infos;

typedef struct 
{
	uint8_t version[2];
	uint8_t cpu_tmp[2][2];
	uint8_t cpu_usage[2];
	mock_infos pcie_infos[MAX_SLOT_NUM];
	int slot_num;
	char pcie_file_path[100];
	time_t last_modify;
	struct stat file_stat;

	time_t imu_last_modify;
	struct stat imu_file_stat;

} imu;

void init_imu(const char *filename, imu* imu_920);
uint8_t *imu_respond(uint8_t *input, const uint32_t *input_length, uint32_t *output_length, imu* imu_920);
void init_pcie_card(const char * filename, imu *imu_920);
void debug_pcie_card(imu *imu_920);

